package com.nexus.core.service.mapstruct;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nexus.core.service.entity.BaseEntity;
import com.nexus.core.service.dto.BaseDTO;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * 通用转换接口
 *
 * @Date 2025/7/24 10:06
 * @Author luzhengning
 **/
public interface BaseConverter<ENTITY extends BaseEntity, DTO extends BaseDTO> {

    @Mappings({
            @Mapping(source = "createBy.id", target = "createBy"),
            @Mapping(source = "updateBy.id", target = "updateBy")})
    ENTITY toEntity(DTO dto);

    @Mappings({
            @Mapping(source = "createBy", target = "createBy.id"),
            @Mapping(source = "updateBy", target = "updateBy.id")})
    DTO toDTO(ENTITY entity);

    List<ENTITY> toEntity(List<DTO> dtoList);

    List<DTO> toDTO(List<ENTITY> entityList);

    Page<ENTITY> toEntity(Page<DTO> page);

    Page<DTO> toDTO(Page<ENTITY> page);
}
